using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

using Excel = Microsoft.Office.Interop.Excel;
using MM.Entities;
using MM.Business;  

namespace MM.Business
{
    public class Common
    {
        protected Excel.Application ExcelApp;
        protected Excel.Workbook objBook;
        protected Excel.Worksheet objSheet;
        protected Excel.Range range;       

       

        public static void PaintGradientColor(Color color1, Color color2, System.Drawing.Drawing2D.LinearGradientMode mode,int width, int height, Form f)
        {
            System.Drawing.Drawing2D.LinearGradientBrush a = new System.Drawing.Drawing2D.LinearGradientBrush(new RectangleF(0, 0, width, height), color1, color2, mode);            
            Graphics frmGraphics = f.CreateGraphics();
            frmGraphics.FillRectangle(a, new RectangleF(0, 0, width, height));
            frmGraphics.Dispose();
        }

        public static  void SetColor(Form f)
        {
            f.BackColor = Color.FromArgb(224,255,255); 	
            //f.BackColor = System.Drawing.ColorTranslator.FromHtml("#CCFFFF");
            //f.BackColor = System.Drawing.ColorTranslator.FromHtml("#D4F4F7");
            foreach (Control c in f.Controls)
            {
                if (c is System.Windows.Forms.Label)
                {
                    c.BackColor = System.Drawing.Color.Transparent;
                }
            }
        }

        public  void ExportPHIEU_YEU_CAU(PHIEU_YEU_CAU pyc, List<CHI_TIET_PYC> lst)
        {
            string err = "";
            object missing = System.Reflection.Missing.Value;
            object fileName = "normal.dot";
            object newTemplate = false;
            object docType = 0;
            object isVisible = true;

            ExcelApp = new Excel.ApplicationClass();
            ExcelApp.Visible = false;
            objBook = ExcelApp.Workbooks.Add(missing);

            objSheet = (Excel.Worksheet)objBook.Sheets[1];
            objSheet.Name = "PHIEU_YEU_CAU";

            objSheet.Cells[1, 1] = pyc.MaPhieuYeuCau;

            ExcelApp.Visible = true;
        }

    }
}
